<template>
	<view>
		<uni-popup ref="companyRealName" type="dialog" :is-mask-click="false">
			<uni-popup-dialog type="info" cancelText="取消认证" confirmText="立即认证" @confirm="dialogConfirm" @close="cancel">
				<template v-slot="content">
					<view class="title">
						<p><span class="round2"></span><span class="round1"></span>
						    <span class="round"></span> 企业实名认证 <span class="round"></span>
						    <span class="round1"></span> <span class="round2"></span>
						</p>
						<img :src="imgPath" alt="" />
					</view>
					
					<view class="msg">
						<view>企业名称：<span class="company-name">{{ currentUser }}</span>
						     <companyGray class="certiyImg" />
						</view>
						<view style="margin: 10rpx 0 15rpx;">
						    认证状态：<span style="color: red;">未实名认证</span>
						</view>
						<view style="margin: 10rpx 0 15rpx;">
							<i class="iconfont icon-huo"></i>
							<span>实名认证后，立得签署量，免费签合同！</span>
						</view>
						<view>
							点击查看：<a href="https://www.lksign.cn/serve/help.html?id=15" target="_blank">企业用户快速入门教程</a>
						</view>
					</view>
					
					<view class="introduce">
						为确保贵单位通过励氪签平台签署的文件结果符合中国国家法律、法规要求以及励氪签为贵单位申请制作的电子签名为贵单位专有，贵单位需要先进行组织实名认证！
					</view>
					
				</template>		
			</uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import companyGray from "@/components/svg/companyGray";
	import { getCompany } from "@/api/ec/work/company/company";
	import { updateSession } from "@/api/ec/person/user/userInfo";
	import { getCertPageRecord} from "@/api/ec/work/company/companyCertification";
	export default {
		name:'companyRealName',
		components:{companyGray},
		data() {
			return {
				imgPath: require("@/static/images/company-cer.png"),
				currentUser:'',
				companyId:'',
			}
		},
		methods: {
			open(id){
				console.log(id)
				this.$refs.companyRealName.open('center')
				this.companyId = id
				this.userInfo();
			},
			// 获取用户信息
			userInfo() {
			  getCompany(this.companyId).then((response) => {
			    this.currentUser = response.data.name;
			  });
			},    
			dialogConfirm(){
				this.$modal.msgSuccess("跳转认证页面");
				getCertPageRecord(this.companyId).then((response) => {
				          let certComanpyForm = response.data;
				          // 认证记录不为空
				          if (!!certComanpyForm) {
							  uni.navigateTo({
								  url: '/pages/authentication' + certComanpyForm.path + '?id=' + this.companyId + '&managerType=' + certComanpyForm.managerType + '&certifyType=' + certComanpyForm.certifyType+ '&companyName=' + certComanpyForm.companyName
							  });
				            // this.$router.push({
				            //   path: certComanpyForm.path,
				            //   query: {
				            //     id: this.companyId,
				            //     managerType: certComanpyForm.managerType,
				            //     certifyType: certComanpyForm.certifyType,
				            //     companyName: certComanpyForm.companyName,
				            //   },
				            // });
				          } else {
							  uni.navigateTo({url: '/pages/authentication/companyRealname/start?id=' + this.companyId});
				            // this.$router.push({
				            //   path: "/companyRealname/start",
				            //   query: { id: this.companyId },
				            // }); 
				          }
				        })
				        .catch(() => {
				          // updateSession().then((response) => {
				          //   cache.session.setJSON("userObj", response.data);
				          // }); 
						  updateSession().then((response) => {
						    this.$store.dispatch('GetInfo').then((res) => {
						    });
						  });
				        });
						
			},
			cancel(){
				this.$refs.companyRealName.close()
			},
		}
	}
</script>
<style lang="scss" scoped>
	.round {
	      height: 22rpx;
	      width: 22rpx;
	      color: #fff;
	      border-radius: 50%;
	      background: #fff;
	      display: inline-block;
	      opacity: 0.7;
	      margin: 4rpx 16rpx 0 16rpx;  
	}
	.round1 {
	      height: 20rpx;
	      width: 20rpx;
	      color: #fff;
	      border-radius: 50%;
	      background: #fff;
	      display: inline-block;
	      opacity: 0.6;
	      margin: 4rpx 16rpx 0 16rpx;  
	}
	.round2 {
	      height: 18rpx;
	      width: 18rpx;
	      color: #fff;
	      border-radius: 50%;
	      background: #fff;
	      display: inline-block;
	      opacity: 0.5;
	      margin: 4rpx 16rpx 0 16rpx;  
	}
	.msg{
		text-align: center;
		margin-top: 90rpx;
		padding: 0 40rpx;
	}
	.icon-huo{
		font-size: 34rpx;
		color: red;
		border: 2rpx solid #fff;
		background: #fff;
	}
	a{
		color: #00a660;
		text-decoration: none;
	}
	.title{
		text-align: center;
		background: #0bb175;
		color: #fff;
		height: 200rpx;
		padding-top: 50rpx;
		font-size: 32rpx;
		border-top-left-radius: 22rpx;
		border-top-right-radius: 22rpx;
		img{
			width: 150rpx;
			height: auto;
			padding-top: 20rpx;
		}
	}
	.certiyImg {
		width: 28rpx;
		height: 30rpx;
		display: inline-block;
		margin: 0 12rpx;
		vertical-align: middle;
	}
	.introduce{
		font-size: 26rpx;
		color: #999;
		text-indent: 2em;
		margin: 26rpx 0;
		padding: 0 40rpx;
		line-height: 40rpx;
	}
	::v-deep .uni-dialog-content{
		display: block;
		padding: 0;
	}
	::v-deep .uni-dialog-title{
		display: none;
	}
	::v-deep .uni-popup-dialog{
		width: 90%;
	}
	
</style>